<script lang="ts" setup>
import { onBeforeMount, onMounted } from "vue";
import Demo from "./demo.tsx";
import { getMessageList } from "@/api/message/message.ts";
import { useMessage } from "@/stores/counter.ts";
const load = async () => {
  let data: any[] = [];
  await getMessageList().then((response) => {
    data = response.data.data;
  });
  data.forEach((item) => {
    if (item.isFromUser == 0) {
      const newAssistantMessage = {
        role: "shangjia",
        id: item.id,
        createAt: Date.now(),
        content: item.content,
      };
      useMessage().message = [...useMessage().message, newAssistantMessage];
    } else {
      const newAssistantMessage = {
        role: "user",
        id: item.id,
        createAt: Date.now(),
        content: item.content,
      };
      useMessage().message = [...useMessage().message, newAssistantMessage];
    }
  });
  console.log(useMessage().message);
};

load();
</script>

<template>
  <h1 style="text-align: center">联系商家</h1>
  <Demo />
</template>
<style lang="less">
.semi-chat {
  max-width: none;
}
</style>
